var xmlHttp;
function GetXmlHttpObject()
{
	var xmlHttp=null;
	  try
	    {
	    // Firefox, Opera 8.0+, Safari
	    xmlHttp=new XMLHttpRequest();
	    }
	  catch (e)
	    {
	    // Internet Explorer
	    try
	      {
	      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	      }
	    catch (e)
	      {
	      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	      }
	    }
	  return xmlHttp;

}

function check_bzr()
{
	xmlHttp = GetXmlHttpObject();
	if(xmlHttp==null)
	{
		alert("浏览器不支持AJAX");
		return;
	}
	var url="check_bzr.do";
	url += "?username="+document.myform.username.value;
	xmlHttp.onreadystatechange=check_bzr_stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function add_bzr()
{
	xmlHttp = GetXmlHttpObject();
	if(xmlHttp==null)
		{
			alert("浏览器不支持AJAX");
			return;
		}
	var url="addAc02.do";
	url += "?username="+document.myform.username.value;  
    url += "&name="+document.myform.name.value;
    url += "&count="+document.myform.count.value;
	xmlHttp.onreadystatechange=add_bzr_stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	
	
}

function add_bzr_stateChanged()
{
	if(xmlHttp.readyState==4)
		{
		var newChild = document.createElement("tr");
		newChild.innerHTML=xmlHttp.responseText;
		document.getElementById("bzr").appendChild(newChild);
		}
}

function check_bzr_stateChanged()
{
	if(xmlHttp.readyState==4)
		{
		if(xmlHttp.responseText == 0)
			{
			alert("用户名  "+document.myform.username.value+" 不能重复!");
			}
		else
		{
		add_bzr();
		}
		}
	
}